using System;
using System.Collections.Generic;
using System.Text;
using JobShopModel.Model.FactoryLvl;

namespace JobShopModel.Model.Job
{
    class Jobs
    {
        private Time startTime;
        private Time finishTime;



        public Time StartTime
        {
            get { return startTime; }
        }
       
        public Time FinishTime
        {
            get { return finishTime; }
            set { finishTime = value; }
        }

        private List<Operation> listOperation;

        private void addOperation(StationsList station,Time time)
        {
            listOperation.Add(new Operation(station,time));
        }

        public Operation getNexOperation()
        {
            Operation rtn = null;
            foreach (Operation o in listOperation)
            {
                if (o.Status == OperationStatus.UNDONE)
                {
                    rtn = o;
                    break;
                }
            }
            return rtn;
        }

        /// <summary>
        /// Private constructor.
        /// </summary>
        private Jobs(Time start)
        {
            this.startTime = start;
            this.listOperation = new List<Operation>();
        }


        public static Jobs CreateJob(JobsTypes type)
        {
            Jobs tmp = new Jobs(Factory.getInstance().CurrentTime);

            switch (type)
            {
                case JobsTypes.JOB1:
                   
                    tmp.addOperation(StationsList.STATION3, new Time(0,0.50));
                    tmp.addOperation(StationsList.STATION1, new Time(0,0.60));
                    tmp.addOperation(StationsList.STATION2, new Time(0,0.85));
                    tmp.addOperation(StationsList.STATION5, new Time(0.50));
                    tmp.addOperation(StationsList.IOSTATION, new Time(0.00));

                    break;

                case JobsTypes.JOB2:

                    tmp.addOperation(StationsList.STATION4, new Time(1.10));
                    tmp.addOperation(StationsList.STATION1, new Time(0.80));
                    tmp.addOperation(StationsList.STATION3, new Time(0.75));
                    tmp.addOperation(StationsList.IOSTATION, new Time(0.00));

                    break;

                case JobsTypes.JOB3:

                    tmp.addOperation(StationsList.STATION2, new Time(1.20));
                    tmp.addOperation(StationsList.STATION5, new Time(0.25));
                    tmp.addOperation(StationsList.STATION1, new Time(0.70));
                    tmp.addOperation(StationsList.STATION4, new Time(0.90));
                    tmp.addOperation(StationsList.STATION3, new Time(1.00));
                    tmp.addOperation(StationsList.IOSTATION,new Time(0.00));

                    break;

            }

            return tmp;
        }

    }
}
